package cn.iocoder.yudao.module.ad.controller.admin.statistics;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.ad.controller.admin.statistics.vo.effect.AdEffectStatisticsCommonReqVO;
import cn.iocoder.yudao.module.ad.controller.admin.statistics.vo.effect.AdEffectStatisticsCommonRespVO;
import cn.iocoder.yudao.module.ad.service.statistics.AdStatisticsEffectService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@RestController
@RequestMapping("/ad/statistics")
public class AdStatisticsController {

    @Resource
    private AdStatisticsEffectService adStatisticsEffectService;

    @GetMapping("/get-summary-by-clue-type")
    @Operation(summary = "获取广告组件类型统计")
    @PreAuthorize("@ss.hasPermission('ad:statistics-effect:query')")
    public CommonResult<List<AdEffectStatisticsCommonRespVO>> getSummaryByClueType(@Valid AdEffectStatisticsCommonReqVO reqVO) {
        return success(adStatisticsEffectService.getSummaryByClueType(reqVO));
    }

    @GetMapping("/get-summary-by-advertiser")
    @Operation(summary = "获取广告账户统计")
    @PreAuthorize("@ss.hasPermission('ad:statistics-effect:query')")
    public CommonResult<List<AdEffectStatisticsCommonRespVO>> getSummaryByAdvertiser(@Valid AdEffectStatisticsCommonReqVO reqVO) {
        return success(adStatisticsEffectService.getSummaryByAdvertiser(reqVO));
    }

    @GetMapping("/get-summary-by-promotion")
    @Operation(summary = "获取广告计划统计")
    @PreAuthorize("@ss.hasPermission('ad:statistics-effect:query')")
    public CommonResult<List<AdEffectStatisticsCommonRespVO>> getSummaryByPromotion(@Valid AdEffectStatisticsCommonReqVO reqVO) {
        return success(adStatisticsEffectService.getSummaryByPromotion(reqVO));
    }
}
